package com.example.demo0604.api;

import com.example.demo0604.bean.ResultBo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    /**
     * 未登录时调用该方法
     */
    @RequestMapping("/notLogin")
    public ResultBo notLogin() {
        return new ResultBo(new Exception("未登录"));
    }

    /**
     *  POST请求 127.0.0.1:8080/viewGoods
     *
     *   {
     *     "code": 0,
     *     "msg": "操作成功",
     *     "data": "viewGoods is ok"
     *   }
     *
     *
     */
    @RequestMapping("/viewGoods")
    public ResultBo viewGoods() {
        return new ResultBo<>("viewGoods is ok");
    }

    /**
     *
     * 用guest用户登录后，携带cookie请求
     * POST请求 127.0.0.1:8080/addGoods
     *
     *  {
     *     "timestamp": "2021-06-04T01:42:05.029+00:00",
     *     "status": 403,
     *     "error": "Forbidden",
     *     "path": "/addGoods"
     * }
     *
     *
     * @return
     */
    @RequestMapping("/addGoods")
    public ResultBo addGoods() {
        return new ResultBo<>("addGoods is ok");
    }
}

